#ifndef CCHARTVIEW_H
#define CCHARTVIEW_H

#include <QtCharts>
#include <QVBoxLayout>

QT_CHARTS_USE_NAMESPACE
#include <QWidget>
#include <QToolBar>
#include <QComboBox>


typedef QPair<QPointF, QString> Data;
typedef QList<Data> DataList;
typedef QList<DataList> DataTable;


class CChartView : public QWidget
{
    Q_OBJECT
public:
    explicit CChartView(QWidget *parent = nullptr);


    void Conbox_addItem();

private:
    void createChart();
    void setupUi();
    int linearEquations(float * data, int rows,float* a, float* b,float* SquarePoor);

    void Sleep(int msec);
    void find_Max_Min();

    QChart*                     m_chart;
    QLineSeries*                m_lineSeries;
    QScatterSeries*             m_scatterSeries;
    QBarCategoryAxis*           m_axis;
    QChartView*                 m_chartView;
    QList<int>                  m_list;

    QVBoxLayout*                m_pMylay;
    QToolBar*                   m_pMybar1;
    QToolBar*                   m_pMybar2;
    QToolBar*                   m_pMybar3;


    QLabel*                     m_pLab[8];
    QComboBox*                  m_pCom[2];
    QPushButton*                m_pHuaTu;
    QPushButton*                m_pNiHe;
    QPushButton*                m_pXuce;
    QLineEdit*                  m_pLin;
//    QValueAxis *                axisX ;
//    QValueAxis *                axisY;

    QLabel *                    m_valueLabel;
    QLabel*                     m_Yuce;

    float                       a_x;
    float                       b_y;

    QPushButton*                m_pStudy;


    CChartView*         m_pChartView;  //

    int index_[5] = {1,2,3,5,6};          //combox对应信息
    float  rang_[5][2] = {
                    150,200,
                    145,190,
                    155,187.5,
                    140,195,
                    20,55
    };


    DataTable m_dataTable;
    QList<float>  max_rang;
    QList<float>  min_rang;


    float  R_2  = 0;    //R2


    QList<QPointF>          m_pAddPoint;
    QList<QPointF>          m_pAddPoint_line;


private slots:
    void slot_drawPointCloud();
    void slot_drawNiheLine();
    void slot_drawShowTest();
    void slot_changeLable();

    void slot_startStudy();
    void slot_clearPoint();

private Q_SLOTS:
    void slot_handleClickedPoint(const QPointF &point);
    void slot_PointHoverd(const QPointF &point, bool state);
signals:

};

#endif // CCHARTVIEW_H
